package arraylist;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Scanner;

public class FoodOperator {
    AbstractList<Food> foodList = new ArrayList<>();
    Scanner sc = new Scanner(System.in);
    //foodList = [food  food  food...]
    //1.对菜品进行上架
    public void putonFood(){
        Food food = new Food();

        System.out.println("请输入菜品名：");
        String name = sc.next();
        food.setName(name);
        System.out.println("请输入价格");
        double price = sc.nextDouble();
        food.setPrice(price);
        System.out.println("请描述菜品：");
        String desc = sc.next();
        food.setDesc(desc);
        foodList.add(food);
        System.out.println("上架成功");
    }

    public void showAllFoods(){
        //展示菜单
        if(foodList.size() == 0){
            System.out.println("暂时还没有菜品哦，亲~");
            return;
        }
        for (int i = 0; i < foodList.size(); i++) {
            Food food = foodList.get(i);
            System.out.println(food.getName());
            System.out.println(food.getPrice());
            System.out.println(food.getDesc());
            System.out.println("---------------------");
        }
    }

    public void start(){
        //用户操作方法
        while (true) {
            System.out.println("请选择功能");
            System.out.println("1、上架菜品");
            System.out.println("2、展示菜单");
            System.out.println("3、退出程序");
            String command = sc.next();
            switch (command){
                case "1":
                    putonFood();
                    break;
                case "2":
                    showAllFoods();
                    break;
                case "3":
                    System.out.println("欢迎下次光临");
                    return;
                default:
                    System.out.println("您输入的命令不存在");
            }
        }
    }
}
